package com.sls.nzdapplication.ui.activity;

import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.ViewPager;

import android.content.Intent;
import android.os.Bundle;

import com.ogaclejapan.smarttablayout.SmartTabLayout;
import com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItem;
import com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItemAdapter;
import com.ogaclejapan.smarttablayout.utils.v4.FragmentPagerItems;
import com.sls.nzdapplication.R;
import com.sls.nzdapplication.app.AppActivity;
import com.sls.nzdapplication.ui.fragment.ZyManagementEquipmentFragment;
import com.sls.nzdapplication.ui.fragment.ZyManagementGtFragment;

/**
 * 这个类是一个继承自AppCompatActivity的Activity，主要用于展示“设备”和“杆塔”两个Fragment。
 * */
public class ZyManagementActivity extends AppActivity {

    String[] tabs = {"设备","杆塔"};
    private Bundle myBundle = new Bundle();
    private String lineId = "";

    @Override
    protected int getLayoutId() {
        return R.layout.activity_zy_management;
    }

    @Override
    protected void initView() {
        Intent intent = getIntent();
        lineId = intent.getStringExtra("lineId");
        myBundle.putString("lineId",lineId);
        //fragment容器类添加两个fragment 用于ViewPage滑动
        FragmentPagerItems pages = new FragmentPagerItems(this);
        pages.add(FragmentPagerItem.of(tabs[0], ZyManagementEquipmentFragment.class,myBundle));
        pages.add(FragmentPagerItem.of(tabs[1], ZyManagementGtFragment.class,myBundle));

        FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(
                getSupportFragmentManager(), pages);

        ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
        viewPager.setAdapter(adapter);
        viewPager.setOffscreenPageLimit(3);


        SmartTabLayout viewPagerTab = (SmartTabLayout) findViewById(R.id.viewpagertab);
        viewPagerTab.setViewPager(viewPager);

    }

    @Override
    protected void initData() {

    }
}